/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lt.ntec.danblog.server.core.model.objectify;

import com.google.appengine.api.users.UserServiceFactory;
import com.google.inject.Inject;
import com.google.inject.Provider;
import lt.ntec.danblog.server.core.model.User;
import lt.ntec.danblog.server.core.model.UserDAO;

/**
 *
 * @author Tadas
 */
class UserProvider implements Provider<User> {
    @Inject
    private UserDAO userDAO;

    @Override
    public User get() {
        com.google.appengine.api.users.User currentUser =
                UserServiceFactory.getUserService().getCurrentUser();
        ObjectifyUser objectifyUser =
                new ObjectifyUser(currentUser);
        userDAO.save(objectifyUser);
        return objectifyUser;
    }
}
